package Week4.J0511;

import java.util.Scanner;

public class 最大子矩阵_xv {
    public static int n;
    public static int[][] dp = new int[110][110]; // 100


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                int x = scanner.nextInt();
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + x;
            }
        }

        int ret = -127;
        for (int x1 = 1; x1 <= n; x1++) {
            for (int y1 = 1; y1 <= n ; y1++) {
                for (int x2 = 1; x2 <= n ; x2++) {
                    for (int y2 = 1; y2 <= n ; y2++) {
                        ret = Math.max(ret,
                                dp[x2][y2] - dp[x1 - 1][y2] - dp[x2 - 1][y1]
                                        + dp[x1 - 1][y1 - 1]);
                    }
                }
            }
        }
        System.out.println(ret);
    }
}
